/*
 * ManagerMenuBar.java
 */

package gui;

import java.awt.event.ActionEvent;
import java.awt.event.InputEvent;

import javax.swing.AbstractAction;
import javax.swing.JMenu;
import javax.swing.JMenuItem;
import javax.swing.KeyStroke;

import model.ListManager;

/**
 * ManagerMenuBar is a menu bar for the ManagerFrame.
 * 
 * @author Sean Brown
 * @version 1.0
 */
@SuppressWarnings("serial")
public class ManagerMenuBar extends UrbanParksMenuBar{

	/**
	 * The ListManager to obtain data from.
	 */
	private ListManager my_lm;
	
	/**
	 * The frame that this menu bar belongs to.
	 */
	private ManagerFrame my_parent;
	
	/**
	 * Constructor instantiates and assigns fields.
	 * 
	 * @param the_login_frame
	 *            The WelcomeFrame that is associated with this menu bar.
	 * @param the_parent_frame
	 *            The JFrame that this menu bar is above.
	 * @param the_lm
	 *            ListManager to obtain data from.
	 */
	public ManagerMenuBar(final WelcomeFrame the_login_frame, 
			final ManagerFrame the_parent_frame, 
			final ListManager the_lm) {
		super(the_login_frame, the_parent_frame, the_lm);
		my_parent = the_parent_frame;
		my_lm = the_lm;
		add(editMenu());
	}
	
	  /**
	   * editMenu method returns a menu containing all components
	   * in the "View" menu.
	   * 
	   * @return file_menu - the "File" menu.
	   */
	  private JMenu editMenu() {
	    final JMenu view_menu = baseMenu("Edit");
	    view_menu.add(new JMenuItem(new NewJobAction()));
	    return view_menu;
	  }
	  
	  /**
	   * An AbstractAction that defines the actions
	   * of the "Add New Job" function.
	   */
	  private class NewJobAction extends AbstractAction {
	    /**
	     * Constructor that sets the title, mnemonic, description
	     * and accelerator keys of the Action.
	     */
	    public NewJobAction() {
	      super("Add New Job");
	      putValue(SHORT_DESCRIPTION, "Add a new job for one of your parks.");
	      putValue(MNEMONIC_KEY, Integer.valueOf('A'));
	      putValue(ACCELERATOR_KEY, 
	               KeyStroke.getKeyStroke('A',
	                                      InputEvent.ALT_MASK));
	    }
	    
	    @Override
	    public void actionPerformed(final ActionEvent the_event) {
	    	new NewJobFrame(my_parent, my_lm).start();
	    }
	  }
}
